package com.example.aijie.autoreadhelper.utils;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;

/**
 * app相关工具类
 */
public class AppUtils {
    /**
     * 根据包名和类名启动app
     *
     * @param packageName 包名
     * @param className   类名
     */
    public static void startApp(Context activity, String packageName, String className) {
        Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_LAUNCHER);
        ComponentName cn = new ComponentName(packageName, className);
        intent.setComponent(cn);
        activity.startActivity(intent);
    }

    /**
     * 返回桌面
     */
    public static void goHome(Context activity) {
        Intent home = new Intent(Intent.ACTION_MAIN);
        home.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        home.addCategory(Intent.CATEGORY_HOME);
        activity.startActivity(home);
    }
}
